//侦听用户是否滑动到底部
let n=0 
window.onscroll=(()=>{
    let end=window.scrollY+window.innerHeight
    let next=document.body.scrollHeight-end+8   
    if(next<1){
        n=n+1        
        let index=n*20
        $('#load').addClass('active')      
        setTimeout(()=>{
            nextfood(index)                   
        },2000)  
    }
})

//得到下一页的食品展示
function nextfood(index){
    AJAX({
        methods:'get',
        url:'https://elm.cangdu.org/shopping/restaurants?latitude=31.22967&longitude=121.4762&offset='+index
    }).then((res)=>{
        getfoods(res)
    }).then(()=>{
        $('#load').removeClass('active')
        console.log('wwawaw')
    })
}